package com.sailing.xjpb.web.base.health;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 自定义健康检查地址（不对任何组件进行健康检查）
 */
@RestController
@RequestMapping(value = "/health")
public class HealthCheck {

    private static final String SUCCESS = "success";
    private static final String TRUE = "true";

    private static final String MESSAGE = "message";
    private static final String OK = "ok";
    private static final String TITLE = "title";

    @Value("${spring.application.name:xjpb-web}")
    private String serviceName;

    @GetMapping(value = "/status")
    public Map<String, Object> check() {
        Map<String, Object> map = new HashMap<>(3);
        map.put(SUCCESS, TRUE);
        map.put(MESSAGE, OK);
        map.put(TITLE, serviceName);
        return map;
    }

}
